<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <link rel="stylesheet" href="../css/myequipment.css">
    <link rel="stylesheet" href="../css/eqconfiguration.css">
    <script src="../js/jquery.min.js"></script>
    <script src="../js/fontzize.js"></script>
    <script src="../js/jsonAjax.js"></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>

</head>
<body>
<div id="app">
    <header>
        <nav onclick="goback()"><img src="../imgs/arrow_left.png"></nav>
        <nav>设备配网</nav>
        <nav></nav>
    </header>
    <section>
        <div class="log_box"><img src="../imgs/configuration.png" />
            <p>请将设备调至配网状态</p>
        </div>
        <div class="shum">
            <img src="../imgs/pwiwanshum.png" />
        </div>
        <div class="input_box">
            <input type="button" class="signin signinup" value="下一步" id="configWXDeviceWiFi">
        </div>
        <div class="input_box">
            <input type="button" class="signin" value="跳过" onclick="skip()">
        </div>
    </section>
</div>
<script type="text/javascript">
    var device_id;
    function GetQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null)return unescape(r[2]);
        return null;
    }
    var myurl = GetQueryString("device_id");
    if (myurl != null && myurl.toString().length > 1) {
        device_id=Number(GetQueryString("device_id").substr(1));
    }
    $.ajax({
        type: "post",
        url: 'http://gh.zayata.com/index.php?s=/Ibox/Web/getSdkConf',
        data: {url:window.location.href},
        dataType: 'json',
    }).done(function (data) {
        wx.config({
            debug: false,
            appId: data.appId,
            timestamp: data.timestamp, // 必填，生成签名的时间戳
            nonceStr: data.nonceStr, // 必填，生成签名的随机串
            signature: data.signature,// 必填，签名，见附录1
            jsApiList : ['configWXDeviceWiFi'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
        });
        document.querySelector('#configWXDeviceWiFi').addEventListener('touchstart', function(){
            WeixinJSBridge.invoke('configWXDeviceWiFi', {}, function(res){
                var err_msg = res.err_msg;
                if(err_msg == 'configWXDeviceWiFi:ok') {
                    window.location.href= golinks("medicationplan.html");
                    return;
                } else {

                }
            });
        });

    })
        .fail(function () {
            console.log("error");
        });
    function skip () {
        window.location.href= golinks("medicationplan.html");
    }
    function goback () {
        history.go(-1)
    }

</script>

</body>

</html>

